
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
node-result-error
Advanced tools
wrapper for data via error class ResultError
npm install node-result-error
# or
yarn add node-result-error
import {ResultOk, ResultFail} from 'node-result';
import {ResultError} from "node-result-error";
function checkParameter(parameters: object, parameterName: string, regExp: RegExp) {
try {
const parameterValue = parameters[parameterName];
if (!regExp.test(parameterValue)) {
return ResultFail(new ResultError({
statusCode: 400,
body: JSON.stringify({
error: 'Unsupported parameter value.',
parameterName,
parameterValue
})
}));
}
return ResultOk(null);
} catch (error) {
return ResultFail(error);
}
}
((ctx) => {
try {
const user = {
firstName: 'Alex',
lastName: '_Smith',
age: '28'
};
checkParameter(user, 'firstName', /^[A-Z][a-z]+$/).unwrap();
checkParameter(user, 'lastName', /^[A-Z][a-z]+$/).unwrap();
checkParameter(user, 'age', /^[1-9][0-9]?$/).unwrap();
ctx.status = 200;
ctx.body = 'ok';
} catch (error) {
if (error instanceof ResultError) {
const data = error.unwrap();
ctx.status = data.statusCode;
ctx.body = data.body;
} else {
console.error(error);
ctx.status = 500;
}
}
})();
FAQs
wrapper for data via error class ResultError
The npm package node-result-error receives a total of 1 weekly downloads. As such, node-result-error popularity was classified as not popular.
We found that node-result-error demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.